/*
 * bisection.h
 *
 *  Created on: Aug 26, 2010
 *      Author: snirgaz
 */

#ifndef BISECTION_H_
#define BISECTION_H_

#include "HelpLibs/def.h"
#include "HelpLibs/RandomGen.h"
#include "WorldLines.h"
#include "EnergyCalc.h"
#include "RandomWalks.h"
#include "SimParams.h"
#include "MoveParams.h"
#include "HelpLibs/ArrayMultiD.h"



enum LeftRight {
	LEFT, RIGHT
};

class Bisection {
private:
	// World Lines Data
	WorldLines *wl_;
	// energy Calculation
	EnergyCalc *energyCalc_;
	// Draw Random Walk
	RandomWalks randomWalks_;
	// QMC Parametes
	QmcParameters * qmcParams_;
	// Move Params
	MoveParams *moveParams_;
	EnergyData energyDiff_;
	WorldLines *lat_;
	int M_;
	// Accept move
	UniformReal zeroOne_;
	//
public:
	void init(WorldLines *wl, QmcParameters * qmcParams, MoveParams *moveParams,
			MTGen *RndGen);
	bool generateBB();
	// Generate a Brownian Motion
	bool generateBBMove();
	// Generate a Random Walk with a Jump
	bool generateRWDMove();
	// Generate Next Level in Levi construction
	bool nextLevel();
	// Generate Next Level Beads
	void nextLevelBeadPos();
	// Generate Next Level random Walk
	void nextLevelRW();
	// calc Swap Move Start Ratio
	bool calcSwap(int originalWL, int swapToWL);
	// Clear All lists
	void clearLists();
	// Dumps Level Values
	void dump_level(int l);
	void dump(int l);
	bool accpetJump(Bead beadTau);
	// Calculate Potential Energy
	WLEnergyData calcEnergy();
	// Calculate Potential Energy of interactions
	EnergyData calcEnergyInteraction();
	// Reject or Accept Move
	bool accept(double p);
};

#endif /* BISECTION_H_ */

